package UserData;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;

public class User_Management implements Serializable {
	public static ArrayList<User_Info> User_list = new ArrayList<User_Info>();
	public static ArrayList<User_Info> Get_User_list = new ArrayList<User_Info>();
	public static User_Info Now_User = null;

	public User_Info find_friend(String ID) {
		User_Info answer = null;
		for (User_Info temp : Get_User_list) {
			if (temp.getID().equals(ID)) {
				answer = temp;

			}
		}

		return answer;
	}

	public int Act_user() {

		int answer = -1;
		for (User_Info temp : Get_User_list) {
			if (temp.isLogin()) {
				Now_User = temp;

				answer = Get_User_list.indexOf(temp);
			}
		}

		return answer;
	}
	
	
	public static void  serOut(){
	
	try{
		FileOutputStream fos = new FileOutputStream("User.dat");
		ObjectOutputStream oos = new ObjectOutputStream(fos);
		oos.writeObject(User_list);
		System.out.println("set:   "+User_list.size());
		oos.close();}catch (Exception e){
		e.printStackTrace();}
		
	}
	
	public static void serIn(){
		
		/*try{
			FileInputStream fileStream = new FileInputStream("User.dat");
			ObjectInputStream ois =  new ObjectInputStream(fileStream);
			Object ob = ois.readObject();
			ArrayList<User_Info> Get_User_list = (ArrayList<User_Info>)ob;
			System.out.println("get:   "+Get_User_list.size());
			ois.close();
			
		}catch (Exception e){
			e.printStackTrace();
		}*/
		
		
		
		
	}
	
	
	
	
}
